﻿using Microsoft.Xna.Framework.Input;
using OilRigSumoWrestlers.Commands;
using RaptorEngine.Managers;

namespace OilRigSumoWrestlers.KeyBindings
{
    class PlayerGamepadBindings : KeyBindingCollection
    {
        public PlayerGamepadBindings(LogicalPlayerIndex player)
        {
            if (player.Equals(LogicalPlayerIndex.One))
            {
                PlayerOneBindings(player);
            }
            else if (player.Equals(LogicalPlayerIndex.Two))
            {
                PlayerTwoBindings(player);
            }
        }

        private void PlayerOneBindings(LogicalPlayerIndex player)
        {
            //Menu
            bindings.Add(GameConstant.MENU + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Button = Buttons.Start
            });
            //Push
            bindings.Add(GameConstant.PUSH + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Button = Buttons.X
            });

            //Menu Forward
            bindings.Add(GameConstant.MENU_FORWARD + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Button = Buttons.A,
                ExtraButton = Buttons.Start
            });

            //Menu Back
            bindings.Add(GameConstant.MENU_BACK + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Button = Buttons.B
            });

            //Menu Next
            bindings.Add(GameConstant.MENU_NEXT + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Button = Buttons.LeftThumbstickDown,
                ExtraButton = Buttons.DPadDown
            });

            //Menu Previous
            bindings.Add(GameConstant.MENU_PREVIOUS + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Button = Buttons.LeftThumbstickUp,
                ExtraButton = Buttons.DPadUp
            });
        }

        private void PlayerTwoBindings(LogicalPlayerIndex player)
        {
            //Menu
            bindings.Add(GameConstant.MENU + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Button = Buttons.Start
            });
            //Push
            bindings.Add(GameConstant.PUSH + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Button = Buttons.X
            });

            //Menu Forward
            bindings.Add(GameConstant.MENU_FORWARD + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Button = Buttons.A,
                ExtraButton = Buttons.Start
            });

            //Menu Back
            bindings.Add(GameConstant.MENU_BACK + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Button = Buttons.B
            });

            //Menu Next
            bindings.Add(GameConstant.MENU_NEXT + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Button = Buttons.LeftThumbstickDown,
                ExtraButton = Buttons.DPadDown
            });

            //Menu Previous
            bindings.Add(GameConstant.MENU_PREVIOUS + player.ToString(), new UseCommand()
            {
                LogicalPlayer = player,
                Button = Buttons.LeftThumbstickUp,
                ExtraButton = Buttons.DPadUp
            });
        }

    }
}
